package com.sunday.common.caffeine.spring.e1_cache;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.Cache;
import org.springframework.cache.caffeine.CaffeineCache;
import org.springframework.cache.caffeine.CaffeineCacheManager;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@RestController
@RequestMapping("/test")
public class CacheApi {

    @Autowired
    private CaffeineCacheManager cacheManager;

    @GetMapping("/send")
    public void send() {
        log.info("{}", cacheManager);
        Cache cache = cacheManager.getCache("cache2");
        assert cache instanceof CaffeineCache;
        CaffeineCache caffeineCache = (CaffeineCache) cache;
        com.github.benmanes.caffeine.cache.Cache<Object, Object> benmanesCache = caffeineCache.getNativeCache();
        log.info("{}", benmanesCache);

    }


}
